#include <iostream>
#include <fstream>
#include <list>
#include <ctype.h>
using namespace std;
class lineReader
{
    char *cuv;
public:
    lineReader ();
    ~lineReader();
    friend ifstream& operator>>(ifstream&, lineReader);
    friend ofstream& operator<<(ofstream&, lineReader);
};


lineReader::lineReader()
{
    cuv=new char [1000];
}

lineReader::~lineReader() {}

ifstream& operator>>(ifstream& in, lineReader l)
{
    char *word,c;
    word=new char[15];
    int i=0;
    int written=0;
    while (!in.eof())
    {
        in.get(c);
        if ((c=='\n') or (c==in.eof()))
        {
            int j=0;
            while(word[j]!='\0')
             {
             l.cuv[written]=word[j];
             j++;
             written++;
             }
            cout<<word<<endl;
            i=0,word=new char[15];
        }
        else if (c==' ')
            i=0,word=new char[15];
        else {
            word[i]=c;
            i++;
        }
    }
    
    return in;
}

ofstream& operator<<(ofstream& out, lineReader l)
{
    out<<l.cuv;
    return out;
}

int main()

{
    ifstream f;
    ofstream g;
    f.open("/Users/cristi/Desktop/cuvinte.in");
    lineReader ss;
    f>>ss;
    f.close();
    g.open("/Users/cristi/Desktop/cuvinte.out");
    g<<ss;
    g.close();
}